package com.hanamaki.exception.demo02;

public class Test_age {

    public static void main(String[] args) {

        try {
            test(120);
        } catch (MyException e) {
            e.printStackTrace();
            System.out.println("年龄不合法");
        } finally {
        }

    }

    public static void test(int age) throws MyException{
        System.out.println("输入的年龄为：" + age);
        if (age < 1 || age > 100) {
            throw new MyException(age);
        } else {
            System.out.println("ok");
        }

    }


}
